c++;模板类test<double>()这么使用有什么作用?(在线)

来源:百度知道 编辑:UC知道 时间:2024/06/23 08:18:56
template<class T> test
{
...
};

在使用时,以这种方式使用是什么意思:
test<double>()
为什么要加个括号?没有书上没有讲啊
.
写错了:
template<clss T> class test
{..};
/////////////////////////////////////////////////////////////////
template<class Type>
struct not_equal_to : public binary_function<Type, Type, bool>
{
bool operator()(
const Type& _Left,
const Type& _Right
) const;
};
//////////////////////////////
// functional_not_equal_to.cpp
// compile

由定义了函数调用操作符的类产生的对象称为函数对象,代码中的 not_equal_to就是那样的类型,not_equal_to<double>( )表示函数对象的调用。

template<class T> test 不是声明了模板么?
test<double>() 应该是构造函数吧?<double>表示模板中的class T以double来代替.

你听过函数对象没

就这个东西

找找相关资料吧

这是functinal头文件里的比较模板函数,先特化,()表示无参数

这是个函数对象,函数对象是将函数对象化的一种方法,既然函数,当然可以传入参数,那么当传入0个参数时,就使用一个空的括号